<template>
	<view class="container">
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="item in swiperlist">
				<view class="swiper-item">
					<image :src="'http://localhost:8090'+item.icon" style="width: 100%;"></image>
				</view>
			</swiper-item>
		</swiper>

		<uni-grid :column="4" style="width: 335.2px; margin-top: 20px;">
			<uni-grid-item v-for="item in gridlist" style="width: 25%;">
				<view
					style="width: 100%;height: 100%;display: flex;flex-direction: column;justify-content: center;align-items: center;">
					<image :src="'http://localhost:8090'+item.icon" style="width: 40px; height: 40px; display: flex;" @click="toSay">
					</image>
					<text>{{item.functionname}}</text>
				</view>
			</uni-grid-item>
		</uni-grid>

		<uni-section :title="meslist.title" type="line" style="margin-top: 20px;" @click="toContent">
			{{meslist.content}}
		</uni-section>

		<uni-section :title="meslist.title" type="line" style="margin-top: 20px;" @click="toContent">
			{{meslist.content}}
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperlist: [],
				gridlist: [],
				meslist: []
			}
		},
		methods: {
			toContent(){
				uni.navigateTo({
					url: '/pages/content/content'
				});
			},
			toSay(){
				uni.navigateTo({
					url: '/pages/say/say'
				})
			}
		},
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/freshmenapp/schoolSwiper/list',
				method: 'POST',
				data: {},
				success: res => {
					this.swiperlist = res.data.list
					uni.showToast({
						title: '成功',
						icon: 'none'
					});
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/freshmenapp/function/list',
				method: 'POST',
				data: {},
				success: res => {
					for(let i=0;i<4;i++){
						this.gridlist.push(res.data.list[i])
					}
					uni.showToast({
						title: '成功',
						icon: 'none'
					});
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/freshmenapp/message/findone',
				method: 'POST',
				data: {
					id: 1
				},
				success: res => {
					this.meslist = res.data.data
					uni.showToast({
						title: '成功',
						icon: 'none'
					});
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
